Inside Macintosh: QuickTime

Previous | Chapter Top | Chapter Contents | Next

Working With Sound Volume

The Movie Toolbox allows you to set the sound volume of movies and tracks. Track volumes allow tracks within a movie to have different volumes. A track's volume is scaled by the movie's volume to produce the track's final volume. Furthermore, the movie's volume is scaled by the sound volume that is returned by the Sound Manager's GetSoundVol routine. Thus, the user can control the overall volume from the Sound control panel.

Volume values range from -1.0 to 1.0. Higher values translate to louder volume. Negative values indicate muted volume. That is, the Movie Toolbox does not play any sound for movies or tracks with negative volume settings, but the original volume level is retained as the absolute value of the volume setting. Therefore, if you want to toggle the current state of the volume, you can invert the sign of the current volume setting, as shown here:

SetMovieVolume (theMovie, -GetMovieVolume (theMovie));

You can use the GetMovieVolume and SetMovieVolume functions to work with a movie's volume.

The GetTrackVolume and SetTrackVolume functions allow you to work with a track's volume.

SetMovieVolume

The SetMovieVolume function allows your application to set a movie's current volume.

pascal void SetMovieVolume (Movie theMovie, short volume);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).
volume
Specifies the current volume setting of the movie represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.
kFullVolume
Sets the movie to full volume (constant value is 1.0).
kNoVolume
Sets the movie to no volume (constant value is 0.0).

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SEE ALSO

Your application can obtain the current volume setting by calling the GetMovieVolume function, which is described in the next section.

GetMovieVolume

The GetMovieVolume function returns a movie's current volume setting.

pascal short GetMovieVolume (Movie theMovie);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

DESCRIPTION

The GetMovieVolume function returns an integer that contains the movie's current volume represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SEE ALSO

You can change a movie's current volume by calling the SetMovieVolume function, which is described in the previous section.

SetTrackVolume

The SetTrackVolume function allows your application to set a track's current volume.

pascal void SetTrackVolume (Track theTrack, short volume);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).
volume
Specifies the current volume setting of the track represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.
kFullVolume
Sets the track to full volume (constant value is 1.0).
kNoVolume
Sets the track to no volume (constant value is 0.0).

DESCRIPTION

Note that, when the track is played, the track's volume is scaled by the volume setting of the movie that contains the track.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

Your application can obtain the current volume setting by calling the GetTrackVolume function, which is described in the next section.

GetTrackVolume

The GetTrackVolume function returns a track's current volume setting.

pascal short GetTrackVolume (Track theTrack);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

DESCRIPTION

The GetTrackVolume function returns an integer that contains the track's current volume represented as a 16-bit, fixed-point number. The high-order 8 bits contain the integer part of the value; the low-order 8 bits contain the fractional part. Volume values range from -1.0 to 1.0. Negative values play no sound but preserve the absolute value of the volume setting.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

You can change a track's current volume by calling the SetTrackVolume function, which is described in the previous section.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next